package org.hgg.workflow.admin.controller;

import org.hgg.workflow.admin.model.Task;
import org.hgg.workflow.admin.service.IWorkFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author Jarvis
 * @date 2023/12/28 20:16
 */
@RestController
public class WorkflowController {

    private IWorkFlowService workFlowService;

    public WorkflowController(IWorkFlowService workFlowService) {
        this.workFlowService = workFlowService;
    }

    @GetMapping("/addTask")
    public Task addTask(String taskName,String pids){
        Task task  =new Task();
        task.setWorkflowId(1);
        task.setTaskName(taskName);
        task.setCreateTime(new Date());
        task.setTaskParents(pids);
        task.setTaskStatus(0);
        workFlowService.insertTask(task);
        return task;
    }
}
